package com.simple.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 角色
 */
@ToString(exclude={"userList"})
@Data
@Entity
@Table(name="sys_role")
@NoArgsConstructor
@AllArgsConstructor
public class SysRole implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name="id",unique=true,nullable=false)
    private Integer id;

    @Column(name="role_name")
    private String roleName;

    @Column(name="menu_id")
    private String menuId;
    @Column(name="create_date")
    @CreatedDate
    private Date createDate;//创建时间
    @Column(name="del_status")
    private Integer delStatus=0;
    @JsonIgnore
    @OneToMany(mappedBy="sysRole",fetch = FetchType.EAGER )//默认懒加载
    @NotFound(action= NotFoundAction.IGNORE)
    private List<SysUser> userList;
}
